linux to see whether the port is occupied and to see all ports [Recommended]
- 2020-11-20 06:21:12
- OfStack
1. Check whether the server port is occupied
> lsof -i:8081
2. View all ports of the server
> netstat -ntlp
3. Check whether the server is open for a port
tcp port: > netstat -ntpl
udp port: > netstat -nupl
Common parameters:
[
-ES28en (all) displays all options, default does not show LISTEN related
-t (tcp) only displays tcp-related options
-u (udp) only displays udp-related options
-n refuses to display aliases and can display all Numbers converted to Numbers.
-l only lists the server status in Listen
-ES45en displays the name of the program to establish the relevant link
-r displays routing information, routing tables
-ES49en displays extended information, such as uid, etc
-s is counted according to each protocol
-c executes the netstat command at regular intervals.
Tip: the status of LISTEN and LISTENING can only be seen with -ES61en or -ES62en
conclusion